package dian.qing.li.demo.security.constants;

import org.springframework.lang.Nullable;

import java.util.HashMap;
import java.util.Map;

public enum DataType {
    USER("1", "用户"),
    ROLE("2", "角色"),
    AUTHORITY("3", "权限"),
    AREA("4", "区域"),
    PROJECT("5", "项目"),
    TAG("6", "标签"),
    DICTIONARY("7", "数字字典"),
    ;

    private String code;
    private String name;

    private DataType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static DataType resolve(@Nullable String code) {
        return code != null ? dataType.get(code) : null;
    }

    private static final Map<String, DataType> dataType = new HashMap(16);

    static {
        DataType[] var0 = values();
        int var1 = var0.length;
        for (int var2 = 0; var2 < var1; ++var2) {
            DataType key = var0[var2];
            dataType.put(key.name(), key);
        }
    }

    @Override
    public String toString() {
        return this.name();
    }
}
